//获取url
var URL = localStorage.getItem("ajaxUrl");

$(function () {
    var url=localStorage.getItem("ajaxUrl");
    var companys = JSON.parse(localStorage.getItem("companys")) ? JSON.parse(localStorage.getItem("companys")) : {};

    //显示登录人员
    $(".panel .content-block p span.user").html(localStorage.getItem("user_name"));
    $(".panel .content-block p span.monitor").html(localStorage.getItem("monitor"));
    $(".panel .content-block p span.companyNameShort").html(companys[localStorage.getItem("cpmpanyCode")] ? companys[localStorage.getItem("cpmpanyCode")].companyNameShort : "");
    //显示 版本号
    $(".panel .content-block p span.bbh").html(localStorage.getItem("version"));

    //点击 个人中心  打开  左侧栏
    $("div.page").on("click", "span.personal", function () {
        $.openPanel("#panel-left-demo");
    });

    //根据缓存的角色,生成内容
    $("#panel-left-demo p.role").show();

    //点击 退出 打开 登录 页面
    $("div.panel").on("click", "p.logout", function () {
        $.confirm('确定退出？', function () {
            //window.location.href="../login.html";
            $.ajax({
                type: "POST",
                url: URL + '/app/logout',
                cache: false,
                success: function (res) {
                    if (res.success) {
                        localStorage.clear();
                        window.location.href = "../login.html";
                    } else {
                        console.log(error);
                        stopWork();
                    }
                },
                error: function (error) {
                    console.log(error);
                    stopWork();
                }
            });
        });
    });

    //点击 当前公司
    var companys = JSON.parse(localStorage.getItem("companys")) ? JSON.parse(localStorage.getItem("companys")) : {};
    var companyHtml = "";
    for (var i in companys) {
        companyHtml += '<option value="'+ i +'">'+ companys[i].companyNameShort +'</option>'
    }
    var cpmpanyCode=localStorage.getItem("cpmpanyCode");
    $("div.panel-left p select.companyNameShort").html(companyHtml).val(cpmpanyCode).trigger("change").prop('disabled', true);
    $("div.panel-left p select.companyNameShort").on("change", function () {
        var company = $(this).val();
        loading_show("切换中...");
        $.ajax({
            headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
            type: "post",
            url: url + '/app/user/switchCompany',
            data: {
                companyCode: company
            },
            dataType: 'json',
            timeout: 60000,
            json: 'callback',
            success: function (res) {
                if (res.success) {
                    //加载提示符 隐藏
                    loading_hide();
                    //console.log(data);
                    $alert(res.companys[res.company].companyNameShort + "，切换成功", 1000);
                    localStorage.setItem("companys", JSON.stringify(res.companys));
                    localStorage.setItem("cpmpanyCode", res.company);
                    localStorage.setItem("jwt", res.jwt);
                    // setTimeout(function () {
                    //     window.location.href = "role.html";
                    // }, 1000);
                } else {
                    //加载提示符 隐藏
                    loading_hide();
                    $alert(res.message);
                }
            },
            error: function (error) {
                //加载提示符 隐藏
                loading_hide();
                $alert(error.message);
            }
        });
    });

    //点击切换角色
    $(".panel-left").on("click", "p.role", function () {
        localStorage.removeItem("machine");
        window.location.href = "role.html";
    });
    //点击 弹框
    $("div.div_role").on("click", function () {
        $(".mengceng").hide();
        $("div.div_role").hide();
        event.stopPropagation();
        event.preventDefault();
    });
    $("div.div_role").on("click", "p.p_role", function () {
        //console.log($(this).find("span.sp_role").text());
        $(".mengceng").hide();
        $("div.div_role").hide();
        window.location.href = "../html/" + $(this).find("span.sp_role").text() + ".html";
        event.stopPropagation();
        event.preventDefault();
    });
});

//输入框为空时 提醒语句
function $alert(title, timeout) {
    $.showPreloaderTitle(title);
    setTimeout(function () {
        $.hidePreloader();
    }, timeout || 1500);
}

function addcookie(name, value, expireHours) {
    var cookieString = name + "#" + value + "; path=/";
    //�ж��Ƿ����ù���ʱ��
    if (expireHours > 0) {
        var date = new Date();
        date.setTime(date.getTime + expireHours * 3600 * 1000);
        cookieString = cookieString + "; expire=" + date.toGMTString();
    }
    document.cookie = cookieString;
}

function getcookie(name) {
    var strcookie = document.cookie;
    var arrcookie = strcookie.split(";");
    for (var i = 0; i < arrcookie.length; i++) {
        var arr = arrcookie[i].split("#");
        if (arr[0] == name) return arr[1];
    }
    return "";
}

function delCookie(name) {//ɾ��cookie
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getcookie(name);
    if (cval != null) document.cookie = name + "#" + cval + "; path=/;expires=" + exp.toGMTString();
}

function stopWork(obj) {
    if (obj.status == "300") {
        var fn = function () {
            $.ajax({
                type: "POST",
                url: URL + '/logout',
                success: function () {
                    localStorage.clear();
                    window.location.href = "../login.html";
                },
                error: function (error) {
                    console.log(error);
                }
            });
        }
        $alert("您已无权操作本工单！", fn);
    } else if (obj.status == "400") {

        var mes = JSON.parse(obj.response);
        $alert(mes.message);
    } else if (obj.status == "404") {
        var mes = JSON.parse(obj.response);
        $alert(mes.message);
    } else if (obj.status == "0") {

        if (navigator.onLine) {
            $alert("网络异常！");
            window.location.reload();
        } else {
            $alert("网络异常！", fn);
            window.location.href = "../login.html";
        }

    } else if (obj.status == "500") {
        $alert("数据异常，请重新登录！");
        window.location.href = "../login.html";
    } else if (obj.status == "401") {
        $alert("登录超时，请重新登录！");
        window.location.href = "../login.html";
    } else if (obj.code == '80001' || obj.code == '80002') {
        var mes = obj.message;
        $alert(mes);
    } else {
        var statu = obj.status;
        $alert("错误：" + statu);
    }
}

//显示 加载中
function loading_show(title) {
    $.showPreloaderTitle(title);
}

function loading_hide() {
    $.hidePreloader();
}

//获取 数组 某个元素的下班
function contains(arrays, obj) {
    var i = arrays.length;
    while (i--) {
        if (arrays[i] == obj) {
            return i;
        }
    }
    return false;
}

function delSpace(str) {
    return str.replace(/\u0000|\u0001|\u0002|\u0003|\u0004|\u0005|\u0006|\u0007|\u0008|\u0009|\u000a|\u000b|\u000c|\u000d|\u000e|\u000f|\u0010|\u0011|\u0012|\u0013|\u0014|\u0015|\u0016|\u0017|\u0018|\u0019|\u001a|\u001b|\u001c|\u001d|\u001e|\u001f|\u007F/g, "");
}

function timeFn(d1, d2) {
    //d1=addDate(d1,-1);
    if (!d2) {
        d2 = new Date()
    }
    var dateBegin = new Date(d1);
    var dateEnd = new Date(d2);
    //console.log(dateBegin);
    //console.log(dateEnd);
    var dateDiff = dateEnd.getTime() - dateBegin.getTime();
    //计算相差分钟数
    var leave2 = dateDiff % (24 * 3600 * 1000 * 3600 * 1000);
    var minutes = Math.floor(leave2 / (60 * 1000));
    return minutes
}


//日期加上一个天数
function addDate(date, days) {
    if (days == undefined || days == '') {
        days = 1;
    }
    var date = new Date(date);
    date.setDate(date.getDate() + days);
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var mm = "'" + month + "'";
    var dd = "'" + day + "'";

    //单位数前面加0
    if (mm.length == 3) {
        month = "0" + month;
    }
    if (dd.length == 3) {
        day = "0" + day;
    }
    var time = date.getFullYear() + "-" + month + "-" + day;
    return time;
}

function addMinutes(data, num) {
    var date = new Date(data);
    var min = date.getSeconds();
    date.setSeconds(min + accMul(num, 60));
    return date;
}


// 加+
function accAdd(arg1, arg2) {
    var r1, r2, m;
    try {
        r1 = arg1.toString().split(".")[1].length;
    } catch (e) {
        r1 = 0;
    }
    try {
        r2 = arg2.toString().split(".")[1].length;
    } catch (e) {
        r2 = 0;
    }
    m = Math.pow(10, Math.max(r1, r2));
    return (arg1 * m + arg2 * m) / m;
}

// 减-
function accSub(arg1, arg2) {
    var r1, r2, m, n;
    try {
        r1 = arg1.toString().split(".")[1].length;
    } catch (e) {
        r1 = 0;
    }
    try {
        r2 = arg2.toString().split(".")[1].length;
    } catch (e) {
        r2 = 0;
    }
    m = Math.pow(10, Math.max(r1, r2));
    n = (r1 >= r2) ? r1 : r2;
    return ((arg1 * m - arg2 * m) / m).toFixed(n);
}

// 乘*
function accMul(arg1, arg2) {
    var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    try {
        m += s1.split(".")[1].length
    } catch (e) {
    }
    try {
        m += s2.split(".")[1].length
    } catch (e) {
    }
    return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}

// 除/
function accDiv(arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try {
        t1 = arg1.toString().split(".")[1].length;
    } catch (e) {
    }
    try {
        t2 = arg2.toString().split(".")[1].length;
    } catch (e) {
    }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""));
        r2 = Number(arg2.toString().replace(".", ""));
        return (r1 / r2) * pow(10, t2 - t1);
    }
}

function zero (number, length) {
    if (number.toString().length >= length) return number;
    return (Array(length).join(0) + number).slice(-length);
}

//获取JSON对象长度
function getJsonLength(jsonData) {
    var length = 0;
    for (var ever in jsonData) {
        length++;
    }
    return length;
}

//算米长根据直径和重量
function setLength(specification, weight) {
    return parseInt(accDiv(weight, accMul(accMul(specification, specification), 0.000006165)));
}

//算重量根据直径和长度
function setWeight(specification, length) {
    return Number(parseFloat(accMul(accMul(accMul(specification, specification), 0.000006165), length)).toFixed(1));
}

// 合绳 标签 打印
function takeupPrint(type, data) {
    if (type == "acidTakeup") {
        cordova.plugins.print.acidTakeup(data.goods_no, (data.inv_model || ""), data.inv_spec, (data.weight_of_wire_rod || 0), function (result) {
        }, function error(error) {
        });
    } else if (type == "silkTakeup" || type == "gjxrollTakeup" || type == "unbondedTakeup" || type == "unbondedDCTakeup") {
        //编号（二维码内容）、物料名称、规格、钢号、长度、净重、客户、排产单号、入库员
        cordova.plugins.print.silkTakeup(
            data.batch,
            (data.inventoryName || ""),
            (data.inventorySpecification || ""),
            (data.inventorySteel || ""),
            (data.availableLength || ""),
            (data.availableQuantity || ""),
            (data.customerName || ""),
            data.workplanNumber,
            (data.inName || ""), function (result) {
        }, function error(error) {
        });
    } else if (type == "heatTakeup") {
        //编号（二维码内容）、物料名称、规格、钢号、净重、客户、排产单号、抗拉强度、上锌量
        var tensileStrengthMin = (data.STANDARD && data.STANDARD.tensileStrengthMin ? data.STANDARD.tensileStrengthMin : "/");
        var tensileStrengthMax = (data.STANDARD && data.STANDARD.tensileStrengthMax ? data.STANDARD.tensileStrengthMax : "/");
        var tensileStrength = tensileStrengthMin + "~" + tensileStrengthMax;
        var zincLayerWeightMin = (data.STANDARD && data.STANDARD.zincLayerWeightMin ? data.STANDARD.zincLayerWeightMin : "/");
        var zincLayerWeightMax = (data.STANDARD && data.STANDARD.zincLayerWeightMax ? data.STANDARD.zincLayerWeightMax : "/");
        var zincLayerWeight = zincLayerWeightMin + "~" + zincLayerWeightMax;
        cordova.plugins.print.heatTakeup(
            data.batch,
            (data.inventoryName || ""),
            (data.inventorySpecification || ""),
            (data.inventorySteel || ""),
            (data.availableQuantity || ""),
            (data.customerName || ""),
            data.workplanNumber,
            tensileStrength,
            zincLayerWeight, function (result) {
            }, function error(error) {
            });
    } else if (type == "gjxtwistwire") {
        // 钢绞线捻股
        //编号（二维码内容）、物料名称、规格、钢号、长度、净重、客户、排产单号、入库员
        cordova.plugins.print.gjxtwistwireTakeup(
            data.batch,
            (data.inventoryName || ""),
            (data.inventorySpecification || ""),
            (data.inventorySteel || ""),
            (data.availableLength || ""),
            (data.availableQuantity || ""),
            (data.customerName || ""),
            data.workplanNumber,
            (data.inName || ""), function (result) {
            }, function error(error) {
            });
    } else if (type == "qualitysampling") {
        //取样标签 编号（二维码内容）、物料名称、规格、钢号、净重、客户、排产单号、抗拉强度、上锌量
        var tensileStrengthMin = (data.STANDARD && data.STANDARD.tensileStrengthMin ? data.STANDARD.tensileStrengthMin : "/");
        var tensileStrengthMax = (data.STANDARD && data.STANDARD.tensileStrengthMax ? data.STANDARD.tensileStrengthMax : "/");
        var tensileStrength = tensileStrengthMin + "~" + tensileStrengthMax;
        var zincLayerWeightMin = (data.STANDARD && data.STANDARD.zincLayerWeightMin ? data.STANDARD.zincLayerWeightMin : "/");
        var zincLayerWeightMax = (data.STANDARD && data.STANDARD.zincLayerWeightMax ? data.STANDARD.zincLayerWeightMax : "/");
        var zincLayerWeight = zincLayerWeightMin + "~" + zincLayerWeightMax;
        cordova.plugins.print.qualitysampling(
            data.batch,
            (data.inventoryName || ""),
            (data.inventorySpecification || ""),
            (data.inventorySteel || ""),
            (data.availableQuantity || ""),
            (data.customerName || ""),
            data.workplanNumber,
            tensileStrength,
            zincLayerWeight, function (result) {
        }, function error(error) {
        });
    } else if (type == "wireProduct") {
        //一二期成品标签：编号（二维码内容）、物料名称、规格、钢号、净重、锌层、日期、抗拉强度、上锌量
        var tensileStrengthMin = (data.STANDARD && data.STANDARD.tensileStrengthMin ? data.STANDARD.tensileStrengthMin : "/");
        var tensileStrengthMax = (data.STANDARD && data.STANDARD.tensileStrengthMax ? data.STANDARD.tensileStrengthMax : "/");
        var tensileStrength = tensileStrengthMin + "~" + tensileStrengthMax;
        var zincLayerWeightMin = (data.STANDARD && data.STANDARD.zincLayerWeightMin ? data.STANDARD.zincLayerWeightMin : "/");
        var zincLayerWeightMax = (data.STANDARD && data.STANDARD.zincLayerWeightMax ? data.STANDARD.zincLayerWeightMax : "/");
        var zincLayerWeight = zincLayerWeightMin + "~" + zincLayerWeightMax;
        cordova.plugins.print.wireProduct(
            data.batch,
            (data.inventoryNamePrint || ""),
            (data.inventorySpecification || ""),
            (data.inventorySteel || ""),
            data.availableQuantity,
            data.zincLayerWeight,
            data.inDate,
            tensileStrength,
            zincLayerWeight, function (result) {
        }, function error(error) {
        });
    } else if (type == "steelStrandProduct") {
        //三期钢绞线成品标签：编号（二维码内容）、物料名称、规格、钢号、净重、日期、抗拉强度
        var tensileStrength = data.inventoryName.split("-")[2] ? data.inventoryName.split("-")[2] : "";
        cordova.plugins.print.wireProduct(
            data.batch,
            (data.inventoryName || ""),
            (data.inventorySpecification || ""),
            (data.inventorySteel || ""),
            data.availableQuantity,
            data.inDate,
            tensileStrength, function (result) {
        }, function error(error) {
        });
    } else if (type == "productback") {
        // 销售退货
        cordova.plugins.print.wireProductback(data.batch, (data.inv_Name || ""), data.inv_Spec, data.quantity, function (result) {
        }, function error(error) {
        });
    } else {
        // 捻向对应
        var nx = {"S": "左", "Z": "右", "sZ": "右交", "zS": "左交", "sS": "左同", "zZ": "右同"};
        if (type == "ropeWire") {
            cordova.plugins.print.initRopeWirewarehouse(
                data.batch,
                (data.segmentLength || ""),
                (data.inventoryName),
                (data.inventorySpecification),
                (data.inventoryStrength || ""),
                (data.availableLength || ""),
                (data.grossQuantity || ""),
                (data.tareQuantity || ""),
                (data.quantity || ""),
                (data.inName),
                (data.inDate || ""),
                (data.customerNameShort || ""),
                (data.nextProcess || ""),
                (data.inventorySteel || ""),
                (data.workplanNumber || ""),
                (data.axleLength || ""), function (result) {
                }, function error(error) {
                });
        }
        else if (type == "twistWire") {
            cordova.plugins.print.initTwistWirewarehouse(
                data.batch,
                data.axleLength || "",
                data.inventoryName || "",
                data.inventorySpecification || "",
                data.inventoryStruct || "",
                data.inventoryDiameter || "",
                (data.inventoryDirection ? data.inventoryDirection + nx[data.inventoryDirection] : ""),
                data.inventorySurface || "",
                data.inventoryStrength || "",
                data.inventoryOil || "",
                data.inDate,
                data.inName,
                data.availableLength,
                (data.ropeInventoryNameSpecification || ""),
                (data.workplanNumber || ""),
                ((data.isShort && data.isShort) == "是" ? "短尺" : ""), function (result) {
                }, function error(error) {
                });
        }
        else if (type == "uniteWire") {
            cordova.plugins.print.initUniteWirewarehouse(
                data.batch,
                data.segmentLength || "",
                data.inventoryName || "",
                data.inventorySpecification || "",
                data.inventoryStruct || "",
                data.inventoryDiameter || "",
                (data.inventoryDirection ? data.inventoryDirection + nx[data.inventoryDirection] : ""),
                data.inventorySurface || "",
                data.inventoryStrength || "",
                data.inventoryOil || "",
                data.inDate,
                data.inName,
                (data.workplanNumber || ""),
                data.availableLength,
                ((data.isShort && data.isShort) == "是" ? "短尺" : ""),
                (data.breakpoint || ""),function (result) {
                }, function error(error) {
                });
        }
        else if (type == "divide") {
            cordova.plugins.print.initDividewarehouse(
                data.batch,
                data.segmentLength || "",
                data.inventoryName || "",
                data.inventorySpecification || "",
                data.inventoryStruct || "",
                data.inventoryDiameter || "",
                data.inventoryDirection || "",
                data.inventorySurface || "",
                data.inventoryStrength || "",
                data.inventoryOil || "",
                data.inDate,
                data.inName,
                data.machine,
                function (result) {
                }, function error(error) {
                });
        }
        else if (type == "hdProduct") {
            cordova.plugins.print.initHDFCwarehouse(
                data.batch,
                data.segmentLength ? data.segmentLength : data.length,
                data.inventoryName || "",
                data.inventorySpecification || "",
                data.inventoryStruct || "",
                data.inventoryDiameter || "",
                data.inventoryDirection || "",
                data.inventorySurface || "",
                data.inventoryStrength || "",
                data.inventoryOil || "",
                data.inDate,
                data.inName,
                data.machine,
                data.grossQuantity,
                data.tareQuantity,
                data.quantity,
                (data.breakpoint || ""),
                function (result) {
                }, function error(error) {
                });
        }
    }
}

// 打印 水箱 拉丝 收线 标签
function printSilkWarehouse(type, data) {
    var qd = "强度  " + (data.tensileStrengthMin || "") + " MPa";
    if (data.shopCode == "F07" && data.inventoryName == "粗拉钢丝") {
        qd = "钢号  " + (data.inventorySteel || "") + "";
    }
    cordova.plugins.print.silkWarehouseXNx(data.batch, (data.inventoryNo || ""), (data.inventoryName.split("-")[1] ? data.inventoryName.split("-")[1] : ""), (data.inventoryDiameter), (qd || ""), (data.wheelLength || ""), (data.grossQuantity || ""), (data.tareQuantity || ""), (data.quantity || ""), (data.inName), (data.inDate || ""),  (data.customerNameShort || ""),  (data.nextProcess || ""),  (data.inventorySteel || ""), (data.standardName || ""), (data.customerProjectNumber || ""), function (result) {
    }, function error(error) {
    });
    // if (type == "手持出口") {
    //     cordova.plugins.print.silkWarehouseCk(data.batch, (data.inventoryNo || ""), (data.inventoryName.split("-")[1] ? getYwinventoryName(data.inventoryName.split("-")[1]) : ""), (data.inventoryDiameter), (data.tensileStrengthMin || ""), (data.length || ""), (data.grossQuantity || ""), (data.tareQuantity || ""), (data.quantity || ""), (data.inName), (data.inDate || ""), function (result) {
    //     }, function error(error) {
    //     });
    // } else if (type == "手持内销") {
    //     cordova.plugins.print.silkWarehouseNx(data.batch, (data.inventoryNo || ""), (data.inventoryName.split("-")[1] ? data.inventoryName.split("-")[1] : ""), (data.inventoryDiameter), (data.tensileStrengthMin || ""), (data.length || ""), (data.grossQuantity || ""), (data.tareQuantity || ""), (data.quantity || ""), (data.inName), (data.inDate || ""), function (result) {
    //     }, function error(error) {
    //     });
    // }
}

function printSilkPalletWarehouse(type, data) {
    if (data.isShort && data.isShort == "是") {
        data.wheelLength = data.length;
    }
    data.inName = localStorage.getItem("user_name");
    if (type == "手持出口") {
        cordova.plugins.print.silkWarehouseCk(data.batch, (data.inventoryNo || ""), (data.inventoryName.split("-")[1] ? getYwinventoryName(data.inventoryName.split("-")[1]) : ""), (data.inventoryDiameter), (data.tensileStrengthMin || ""), (data.wheelLength || ""), (data.grossQuantity || ""), (data.tareQuantity || ""), (data.quantity || ""), (data.inName), (data.inDate || ""), (data.weld || ""), (data.standardName || ""), (data.customerNameShort || ""), function (result) {
        }, function error(error) {
        });
    } else if (type == "手持内销") {
        cordova.plugins.print.silkWarehouseNx(data.batch, (data.inventoryNo || ""), (data.inventoryName.split("-")[1] ? data.inventoryName.split("-")[1] : ""), (data.inventoryDiameter), (data.tensileStrengthMin || ""), (data.wheelLength || ""), (data.grossQuantity || ""), (data.tareQuantity || ""), (data.quantity || ""), (data.inName), (data.inDate || ""), (data.weld || ""), (data.standardName || ""), (data.customerNameShort || ""), function (result) {
        }, function error(error) {
        });
    } else if (type == "东台亿阳") {
        cordova.plugins.print.silkWarehouseDtyy(data.batch, (data.inventoryNo || ""), (data.inventoryName.split("-")[1] ? data.inventoryName.split("-")[1] : ""), (data.inventoryDiameter), (data.tensileStrengthMin || ""), (data.wheelLength || ""), (data.grossQuantity || ""), (data.tareQuantity || ""), (data.quantity || ""), (data.inName), (data.inDate || ""), (data.weld || ""), (data.standardName || ""), (data.customerNameShort || ""), (data.inventorySteel || ""), function (result) {
        }, function error(error) {
        });
    }
}

function getYwinventoryName(inventoryName) {
    if (inventoryName == "镀锌") {
        return "Galvanized Steel Wire";
    } else if (inventoryName == "光面") {
        return "Bright Steel Wire";
    } else {
        return "";
    }
}

Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

//console.log(new Date().Format("yyyy-MM-dd hh:mm:ss"));

function RemoveChinese(strValue) {
    if (strValue != null && strValue != "") {
        var reg = /[\u4e00-\u9fa5]/g;
        return strValue.replace(reg, "");
    } else return "";
}

//时间格式 转换
function setDate(date) {
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    var minute = date.getMinutes();
    minute = minute < 10 ? ('0' + minute) : minute;
    var second = date.getSeconds();
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
}


//停机，开始按钮
function machineStopStare(type) {
    if (type == "stop") {
        $(".bnt .stop").hide();
        $(".bnt .start").show();
    } else {
        $(".bnt .stop").show();
        $(".bnt .start").hide();
    }
}

